package com.lims.kafka.consumer;

import com.lims.kafka.TopicConts;
import com.lims.service.ITestUserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.List;


@Slf4j
@Component
public class TestConsumer {
    @Resource
    ITestUserService testUserService;

    /**
     * 批量消费,配置批量消费最大限制为50条，concurrency = "10"配置并发线程数，所以没次理论消费量为50*10 = 500条
     * @param messageList
     */
    @KafkaListener(topics = TopicConts.TEST_TOPIC,groupId = TopicConts.TEST_TOPIC_GROUP_ID,
            concurrency = "10",containerFactory = "batchFactory")
    public void onMessage(List<String> messageList){
        log.info("TestConsumer消费告警数:{}", messageList.size());
        testUserService.dealMessageList(messageList);
    }
}
